#include "comLogManager.h"
#include "IconImageMgr.h"

#include "ttcodeStateChart.h"


bool IconImageMgr::m_Init = false;

IconImageMgr::IconImageMgr( void )
:m_ImgList(NULL)
,m_IconPath(globalTTEnv["res_home"] + "/icons/16x16")
{
	if( false == m_Init )
	{
		m_Init = true;
	}
	m_ImgList = new wxImageList(16,16);
	try
	{
		{
			wxImage img;
			img.LoadFile(m_IconPath + "/taotie.png",wxBITMAP_TYPE_PNG);
			wxBitmap bitmap(img);
			m_ImgMgr["taotie"] = m_ImgList->Add(bitmap);
			wxIcon icon;
			icon.CopyFromBitmap(bitmap);
			m_IconList["taotie"] = icon;
		}
		{
			wxImage img;
			img.LoadFile(m_IconPath + "/docment.png",wxBITMAP_TYPE_PNG);
			wxBitmap bitmap(img);
			m_ImgMgr["docment"] = m_ImgList->Add(bitmap);
			wxIcon icon;
			icon.CopyFromBitmap(bitmap);
			m_IconList["docment"] = icon;
		}
		{
			wxImage img;
			img.LoadFile(m_IconPath + "/targets.png",wxBITMAP_TYPE_PNG);
			wxBitmap bitmap(img);
			m_ImgMgr["targets"] = m_ImgList->Add(bitmap);
			wxIcon icon;
			icon.CopyFromBitmap(bitmap);
			m_IconList["targets"] = icon;
		}
		{
			wxImage img;
			img.LoadFile(m_IconPath + "/execute.png",wxBITMAP_TYPE_PNG);
			wxBitmap bitmap(img);
			m_ImgMgr["execute"] = m_ImgList->Add(bitmap);
			wxIcon icon;
			icon.CopyFromBitmap(bitmap);
			m_IconList["execute"] = icon;
		}
		{
			wxImage img;
			img.LoadFile(m_IconPath + "/staticLib.png",wxBITMAP_TYPE_PNG);
			wxBitmap bitmap(img);
			m_ImgMgr["static"] = m_ImgList->Add(bitmap);
			wxIcon icon;
			icon.CopyFromBitmap(bitmap);
			m_IconList["static"] = icon;
		}
		{
			wxImage img;
			img.LoadFile(m_IconPath + "/sharedLib.png",wxBITMAP_TYPE_PNG);
			wxBitmap bitmap(img);
			m_ImgMgr["shared"] = m_ImgList->Add(bitmap);
			wxIcon icon;
			icon.CopyFromBitmap(bitmap);
			m_IconList["shared"] = icon;
		}
		{
			wxImage img;
			img.LoadFile(m_IconPath + "/head.png",wxBITMAP_TYPE_PNG);
			wxBitmap bitmap(img);
			m_ImgMgr["head"] = m_ImgList->Add(bitmap);
			wxIcon icon;
			icon.CopyFromBitmap(bitmap);
			m_IconList["head"] = icon;
		}
		{
			wxImage img;
			img.LoadFile(m_IconPath + "/cstd.png",wxBITMAP_TYPE_PNG);
			wxBitmap bitmap(img);
			m_ImgMgr["cstd"] = m_ImgList->Add(bitmap);
			wxIcon icon;
			icon.CopyFromBitmap(bitmap);
			m_IconList["cstd"] = icon;
		}
		{
			wxImage img;
			img.LoadFile(m_IconPath + "/cpp.png",wxBITMAP_TYPE_PNG);
			wxBitmap bitmap(img);
			m_ImgMgr["cpp"] = m_ImgList->Add(bitmap);
			wxIcon icon;
			icon.CopyFromBitmap(bitmap);
			m_IconList["cpp"] = icon;
		}
		{
			wxImage img;
			img.LoadFile(m_IconPath + "/text.png",wxBITMAP_TYPE_PNG);
			wxBitmap bitmap(img);
			m_ImgMgr["text"] = m_ImgList->Add(bitmap);
			wxIcon icon;
			icon.CopyFromBitmap(bitmap);
			m_IconList["text"] = icon;
		}
		{
			wxImage img;
			img.LoadFile(m_IconPath + "/folder.png",wxBITMAP_TYPE_PNG);
			wxBitmap bitmap(img);
			m_ImgMgr["folder"] = m_ImgList->Add(bitmap);
			wxIcon icon;
			icon.CopyFromBitmap(bitmap);
			m_IconList["folder"] = icon;
		}
	}
	catch(...)
	{
		ttcode_log << "image create error" << endl;
	}

}

